# -*- coding: UTF-8 -*-

from common.Common import *
from common.Constants import *
from mysql.CUR2MySQL import crud
from spider.bytravel.BytravelSpiderMethods import getAllProvinceAndDistrict, getAllDistrictSpecialty, \
    getSpecialtiesContent

logger = Logger.get_logger(__name__)


def main():
    website = 'bytravel'
    logger.info("===开始爬取 %s <%s> 网站数据===" % (websites_chs[website], websites[website]))

    # 爬取首页所有省份和地区
    list = getAllProvinceAndDistrict(website)

    # 爬取每个区域的特产信息
    # TODO 调试用代码
    # list = getAllDistrictSpecialty(list[-4:-2])
    list = getAllDistrictSpecialty(list)

    # 获取文章内容
    # list = getSpecialtiesContent(list)

    # 保存所有内容到数据库
    crud(list)

    return 0


if __name__ == "__main__":
    main()